package cn.tedu.jdbc;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;

public class HomeWork1 {
    public static void main(String[] args) throws Exception {
        Class.forName("com.mysql.cj.jdbc.Driver");
        String url="jdbc:mysql://localhost:3307/cgb211101";
        Connection c = DriverManager.getConnection(url, "root", "root");
        Statement s = c.createStatement();
       // s.executeUpdate("insert into user values(5,'lucy',123)");
       // s.executeUpdate("delete from user  where id=5");
       // s.executeUpdate(" update user set id=2 where id=3");
        ResultSet r = s.executeQuery("select * from user ");



        while (r.next()){
            Object r1 = r.getObject(1);
            Object r2 = r.getObject(2);
            Object r3 = r.getObject(3);
            System.out.println(""+r1+r2+r3);

        }

        c.close();
        s.close();
        r.close();
    }
}
